package com.backend.securitiessystem.controller;

import com.backend.securitiessystem.dto.IndexDto;
import com.backend.securitiessystem.pojo.Index;
import com.backend.securitiessystem.result.Result;
import com.backend.securitiessystem.service.IndexService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 中国指数 controller
 *
 * @author LWY
 * @date 2024-05-21 03:40:43
 */
@RestController
@Slf4j
public class IndexController {

    @Resource
    private IndexService indexService;


    @GetMapping("/getChinaIndexByPage")
    public Result<IPage<IndexDto>> getIndexByPage(
            @RequestParam(defaultValue = "2") Integer pageNum,
            @RequestParam(defaultValue = "2") Integer pageSize
    ) {

        QueryWrapper<Index> queryWrapper=new QueryWrapper<>();

        IPage<IndexDto> indexDtoIPage= indexService
                .selectPageWithCondition(pageNum,pageSize,queryWrapper);
        log.info("获取中国指数分页数据: {}", indexDtoIPage);

        return Result.success(indexDtoIPage);
    }
}
